package com.lin.factory;


/**
 * 生产披萨的抽象工厂
 * @author linfenliang
 *
 */
public abstract class PizzaStore {

	public Pizza orderPizza(String type){
		Pizza pizza = createPizza(type);
		pizza.prepare();
		pizza.bake();
		pizza.cut();
		pizza.box();
		return pizza;
	}
	/**
	 * 定义抽象工厂方法，子类实现该方法制造披萨
	 * 
	 * @param type
	 * @return
	 * Pizza
	 * @Date 2016年1月8日
	 * @Version 1.0
	 * @Author linfenliang
	 */
	public abstract Pizza createPizza(String type);
}
/**
 * 纽约披萨分店
 * @author linfenliang
 *
 */
class NYPizzaStore extends PizzaStore{
	PizzaIngredientFactory factory = new NYPizzaIngredientFactory();

	@Override
	public Pizza createPizza(String type) {//纽约披萨分店提供不同种类的披萨
		Pizza pizza;
		if("1".equals(type)){
			pizza = new NYStyleCheesePizza(factory);
		}else if("2".equals(type)){
			pizza = new NYStyleVeggiePizza(factory);
		}else{
			pizza = new ChicagoStyleCheesePizza(factory);
		}
		return pizza;
	}
	
}
class ChicagoPizzaStore extends PizzaStore{
	PizzaIngredientFactory factory = new NYPizzaIngredientFactory();
	@Override
	public Pizza createPizza(String type) {
		return new ChicagoStyleCheesePizza(factory);
	}
	
}